package com.imay.live.helper;

import android.content.Context;

import com.imay.base.util.StringUtil;
import com.imay.live.R;

/**
 * Created by  nick on 2017/4/20 0020.
 */

public class SystemNoticeHelper {

    public static final int TYPE_SYSTEM_REWARD = 1;
    public static final int TYPE_USER_UPGRAD = 2;
    public static final int TYPE_ANCHOR_UPGRAD = 3;
    public static final int TYPE_OFFICIAL_NOTICE = 4;
    public static final int TYPE_SETTLEMENT_NOTICE = 5;
    public static final int TYPE_PROPS_INFO = 7;
    public static final int TYPE_IMAY = 8;
    public static final int TYPE_ACTIVITY_INFO = 9;
    public static final int TYPE_CUSTOMER_SERVICE = 10;
    public static final int TYPE_SYSTEM_FAMILY = 12;

    public static int getIconByType(int type) {
        int imageId = 0;
        switch (type) {
            case TYPE_SYSTEM_REWARD:
                imageId = R.mipmap.ico_05_xttongzhi_xtjiangli;
                break;
            case TYPE_USER_UPGRAD:
                imageId = R.mipmap.ico_05_xttongzhi_user;
                break;
            case TYPE_ANCHOR_UPGRAD:
                imageId = R.mipmap.ico_05_xttongzhi_zhubo;
                break;
            case TYPE_OFFICIAL_NOTICE:
                imageId = R.mipmap.ico_05_xttongzhi_guanfangtongzhi;
                break;
            case TYPE_SETTLEMENT_NOTICE:
                imageId = R.mipmap.ico_05_xttongzhi_tixian;
                break;
            case TYPE_PROPS_INFO:
                imageId = R.mipmap.ico_05_xttongzhi_gift;
                break;
            case TYPE_IMAY:
                imageId = R.mipmap.ico_05_xttongzhi_imay;
                break;
            case TYPE_ACTIVITY_INFO:
                imageId = R.mipmap.ico_05_xttongzhi_huodong;
                break;
            case TYPE_CUSTOMER_SERVICE:
                imageId = R.mipmap.ico_05_xttongzhi_kefu;
                break;
            case TYPE_SYSTEM_FAMILY:
                imageId = R.mipmap.ico_05_xttongzhi_qun;
                break;
        }

        return imageId;
    }

    public static int getTextByType(int type) {
        int stringId = TYPE_SYSTEM_REWARD;
        switch (type) {
            case TYPE_SYSTEM_REWARD:
                stringId = R.string.system_notice_xitongjiangli;
                break;
            case TYPE_USER_UPGRAD:
                stringId = R.string.system_notice_yonghushenji;
                break;
            case TYPE_ANCHOR_UPGRAD:
                stringId = R.string.system_notice_zhuboshengji;
                break;
            case TYPE_OFFICIAL_NOTICE:
                stringId = R.string.system_notice_guangfangtongzhi;
                break;
            case TYPE_SETTLEMENT_NOTICE:
                stringId = R.string.system_notice_jiesuantongzhi;
                break;
            case TYPE_PROPS_INFO:
                stringId = R.string.system_notice_daojuxinxi;
                break;
            case TYPE_IMAY:
                stringId = R.string.system_notice_xiaozhushou;
                break;
            case TYPE_ACTIVITY_INFO:
                stringId = R.string.system_notice_huodongxinxi;
                break;
            case TYPE_CUSTOMER_SERVICE:
                stringId = R.string.system_notice_kefu;
                break;
            case TYPE_SYSTEM_FAMILY:
                stringId = R.string.system_notice_family;
                break;
        }

        return stringId;
    }

    /**
     * 拼装系统通知文案
     *
     * @param context
     * @param contentType
     * @param contentId
     * @param parameters
     * @return
     */
    public static String getContent(Context context, int contentType, int contentId, String parameters) {
        String content = "";
        if (StringUtil.isEmpty(parameters)) {
            return content;
        }


        switch (contentType) {
            case TYPE_USER_UPGRAD://用户升级 2
            {
                if (contentId == 2) {
                    content = String.format(context.getString(R.string.system_notice_user_upgrad), parameters);
                }
            }
            break;
            case TYPE_ANCHOR_UPGRAD://主播升级 3
            {
                if (contentId == 9) {
                    content = String.format(context.getString(R.string.system_notice_anchor_upgrad), parameters);
                }

            }
            break;
            case TYPE_OFFICIAL_NOTICE://官方通知 4
            {
                switch (contentId) {
                    case 3: {
                        content = context.getString(R.string.system_notice_account_lock);


                    }
                    break;
                    case 4: {
                        content = context.getString(R.string.system_notice_account_unlock);

                    }
                    break;
                    case 5: {
                        content = context.getString(R.string.system_notice_room_lock);


                    }
                    break;
                    case 6: {
                        content = context.getString(R.string.system_notice_room_unlock);

                    }
                    break;
                    case 7: {
                        content = context.getString(R.string.system_notice_real_name_pass);

                    }
                    break;
                    case 8: {
                        content = context.getString(R.string.system_notice_vip_pass);

                    }
                    break;
                    case 12: {
                        content = String.format(context.getString(R.string.system_notice_real_name_refuse_resean), parameters);

                    }
                    break;
                    case 13: {
                        content = context.getString(R.string.system_notice_real_name_refuse);

                    }
                    break;
                    case 14: {
                        if (!parameters.contains("||")) {
                            return parameters;
                        }
                        String[] parameterArr = parameters.split("\\|\\|");
                        if (parameterArr.length == 6) {
                            content = String.format(context.getString(R.string.system_notice_receipts_account), parameterArr[0], parameterArr[1], parameterArr[2], parameterArr[3], parameterArr[4], parameterArr[5]);
                        }
                    }
                    break;
                    case 15: {
                        content = String.format(context.getString(R.string.system_notice_recharge), parameters);

                    }
                    break;

                    default:
                        break;
                }
            }
            break;
            case TYPE_PROPS_INFO://道具信息 7
            {
                switch (contentId) {
                    case 10: {
                        content = String.format(context.getString(R.string.system_notice_props), parameters);
                    }
                    break;
                    case 11: {
                        content = String.format(context.getString(R.string.system_notice_drive), parameters);
                    }
                    break;

                    default:
                        break;
                }
            }
            break;
            case TYPE_IMAY://iMAY小助手 8
            {
                if (contentId == 1) {
                    content = context.getString(R.string.system_notice_profile);
                }
            }
            break;
            case TYPE_SYSTEM_FAMILY:
                switch (contentId) {
                    case 16: {
                        content = String.format(context.getString(R.string.system_notice_family_create_success), parameters);
                    }
                    break;
                    case 17: {
                        content = context.getString(R.string.system_notice_family_disband);
                    }
                    break;
                    case 18: {
                        content = String.format(context.getString(R.string.system_notice_family_create_check), parameters);
                    }
                    break;
                    case 19: {
                        if (!parameters.contains("||")) {
                            return parameters;
                        }
                        String[] parameterArr = parameters.split("\\|\\|");
                        if (parameterArr.length == 2) {
                            content = String.format(context.getString(R.string.system_notice_family_lvupgrade), parameterArr[0], parameterArr[1]);
                        }
                    }
                    break;
                    case 20: {
                        content = String.format(context.getString(R.string.system_notice_family_kiout), parameters);
                    }
                    break;
                    case 21: {
                        content = String.format(context.getString(R.string.system_notice_family_join_check), parameters);
                    }
                    break;
                    case 22: {
                        content = String.format(context.getString(R.string.system_notice_family_join_success), parameters);
                    }
                    break;
                    case 23: {
                        if (!parameters.contains("||")) {
                            return parameters;
                        }
                        String[] parameterArr = parameters.split("\\|\\|");
                        if (parameterArr.length == 2) {
                            content = String.format(context.getString(R.string.system_notice_family_create_failure), parameterArr[0], parameterArr[1]);
                        }
                    }
                    break;
                    case 24: {
                        content = String.format(context.getString(R.string.system_notice_family_join_falure), parameters);
                    }
                    break;
                    case 25: {
                        content = context.getString(R.string.system_notice_family_lock);
                    }
                    break;
                    case 26: {
                        content = context.getString(R.string.system_notice_family_unlock);
                    }
                    break;
                    case 27: {
                        content = String.format(context.getString(R.string.system_notice_family_change), parameters);
                    }
                    default:
                        break;
                }
                break;
            default:
                break;
        }
        return content;
    }

}

